home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7580 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  54 lines

  1. Path: iconet.hongkong.net!wong.yuk.wah%f18.n1000.z128
  2. From: wong.yuk.wah%f18.n1000.z128@iconet.hongkong.net (Wong Yuk Wah)
  3. Newsgroups: comp.lang.c
  4. Subject: Passing struct in para.
  5. Distribution: world
  6. Message-ID: <56d1d38a56d1d38a@iconet.hongkong.net>
  7. Date: Tue, 27 Feb 1996 16:49:00 HKT
  8. Organization: IcoNET (HONG KONG) <--> Internet gateway
  9. X-Mailer: MailGate 0.25+
  10. Reply-To:  Wong Yuk Wah <Wong.Yuk.Wah%f18.n1000.z128@iconet.hongkong.net>
  11.  
  12.  -=> Quoting xiaoyi@mozart.bme.ohio-state.edu to All <=-
  13.  
  14. Hi Wu,
  15.  
  16.  x> Can we pass the copy of a structure in the para. list?
  17.  
  18. Yes, structure is like a normal variable, and it is passed by value
  19. under normal situations. For example,
  20.  
  21. struct x {
  22.    ...
  23. };
  24.  
  25. typedef struct x X;
  26.  
  27. void func(int, X);
  28.  
  29. main()
  30. {
  31.    int y;
  32.    X z;
  33.  
  34.    /* plus some initialization */
  35.  
  36.    func(y, z);
  37.    ...
  38.    return 0;
  39. }
  40.  
  41. void func(int a, X b)
  42. {
  43.    ...
  44. }
  45.  
  46. This will pass a copy of z to func, just as y does.
  47.  
  48. Regards,
  49. Wong Yuk Wah
  50.  
  51. ... This is not a tagline.
  52.  
  53. * Origin: IcoNET <--> Internet/Usenet gateway, 128:1000/1 (128:1000/1)
  54.